package kr.hkit.androidcomplete01.ch14;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.TextView;

public class AttributeTest extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch14_attributetest);
		
		AttrButton btn = (AttrButton) findViewById(R.id.attrBtn);
		TextView text = (TextView) findViewById(R.id.attrtext);
		text.setText(btn.mText);
	}
	
	public class AttrButton extends Button{
		String mText = ""; 
		public AttrButton(Context context, AttributeSet attrs) {
			super(context, attrs);
			
			int i;
			String name;
			String value;
			for(i=0; i<attrs.getAttributeCount(); i++){
				name = attrs.getAttributeName(i);
				value = attrs.getAttributeValue(i);
				mText += (name + " = " + value + "\n");
			}
		}
	}
}
